library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
"%&%" = function(a,b) paste(a,b,sep="")

for(pop in c('AFA-CAU','AFA-HIS','CAU-HIS')){
  res <- read.table(pop %&% '_MESA_Nk-20.local-h2_gen-corr.2017-07-21_with_SNP_count.txt',header=T)
  res <- dplyr::mutate(res,min.h2=ifelse(pop1.h2<pop2.h2,pop1.h2,pop2.h2), max.h2=ifelse(pop1.h2>pop2.h2,pop1.h2,pop2.h2))
  print(summary(res))
  print(ggplot(res, aes(x=rG,y=pop1.h2)) + geom_point() + ggtitle(pop))
  print(ggplot(res, aes(x=rG,y=pop1.se)) + geom_point() + ggtitle(pop))
  print(ggplot(res, aes(x=pop1.h2,y=pop1.se)) + geom_point() + ggtitle(pop))
  print(ggplot(res, aes(x=rG,y=pop2.h2)) + geom_point() + ggtitle(pop))
  print(ggplot(res, aes(x=rG,y=pop2.se)) + geom_point() + ggtitle(pop))
  print(ggplot(res, aes(x=pop2.h2,y=pop2.se)) + geom_point() + ggtitle(pop))
  print(ggplot(res, aes(x=pop1.h2,y=pop2.h2,col=rG)) + geom_point()+scale_color_gradientn(colours = rainbow(4)) + ggtitle(pop))
  print(ggplot(res, aes(x=pop1.h2,y=pop2.h2)) + stat_density_2d(aes(fill = ..level..), geom = "polygon") + ggtitle(pop))
  print(ggplot(res, aes(x=pop1.h2,y=pop2.h2,col=log10(rG.se))) + geom_point() +scale_color_gradientn(colours = rainbow(4)) + ggtitle(pop))
  
  print(ggplot(res, aes(x=rG,y=log10(rG.se),col=min.h2)) + geom_point(alpha=0.5)+scale_color_gradientn(colours = rainbow(4)) + ggtitle(pop))
  print(ggplot(res, aes(x=rG,y=log10(rG.se),col=max.h2)) + geom_point(alpha=0.5)+scale_color_gradientn(colours = rainbow(4)) + ggtitle(pop))
  print(ggplot(res, aes(x=rG,y=log10(rG.se))) + stat_density_2d(aes(fill = ..level..), geom = "polygon") +
    coord_cartesian(xlim=c(-1,1)) + ggtitle(pop))
  
  #keep only genes with h2>0.2 in one pop
  resfilt <- dplyr::filter(res, pop1.h2 > 0.2 | pop2.h2 > 0.2) 
  resfilt <- dplyr::mutate(resfilt,min.h2=ifelse(pop1.h2<pop2.h2,pop1.h2,pop2.h2), max.h2=ifelse(pop1.h2>pop2.h2,pop1.h2,pop2.h2))
  print(summary(resfilt))
  print(ggplot(resfilt, aes(x=rG,y=log10(rG.se))) + geom_point(alpha=0.5) + ggtitle(pop))
  print(ggplot(resfilt, aes(x=rG,y=log10(rG.se),col=min.h2)) + geom_point(alpha=0.5)+scale_color_gradientn(colours = rainbow(4)) + ggtitle(pop))
  print(ggplot(resfilt, aes(x=rG,y=log10(rG.se),col=max.h2)) + geom_point(alpha=0.5)+scale_color_gradientn(colours = rainbow(4)) + ggtitle(pop))
  print(ggplot(resfilt, aes(x=rG,y=log10(rG.se))) + stat_density_2d(aes(fill = ..level..), geom = "polygon") +
    coord_cartesian(xlim=c(-1,1)) + ggtitle(pop))
  
  
  print(ggplot(res, aes(x=rG,y=log10(rG.se))) + stat_density_2d(geom = "point", aes(size = ..density..), n = 20, contour = FALSE) + ggtitle(pop))
  print(ggplot(res, aes(x=rG)) + geom_density() + ggtitle(pop))
  print(ggplot(res, aes(x=log10(rG.se))) + geom_density() + ggtitle(pop))
  print(ggplot(res, aes(x=pop1.h2)) + geom_density() + ggtitle(pop))
  print(ggplot(res, aes(x=pop2.h2)) + geom_density() + ggtitle(pop))
  print(ggplot(res, aes(x=rG,y=log10(rG.se))) + geom_bin2d() + ggtitle(pop))
  print(ggplot(res, aes(x=rG,y=log10(rG.se),col=pop1.h2)) + geom_point() + ggtitle(pop))
  
  print(ggplot(res, aes(x=rG,y=log10(pop1.snpcount)))+geom_point(alpha=0.5)+geom_smooth(stat="smooth")  + ggtitle(pop))
  print(ggplot(res, aes(x=rG,y=log10(pop2.snpcount)))+geom_point(alpha=0.5)+geom_smooth(stat="smooth")  + ggtitle(pop))
  cor.test(res$rG,res$pop1.snpcount,method='s')
  cor.test(res$rG,res$pop2.snpcount,method='s')
}
##                pop.data          N                      ensid     
##  AFA-CAU_MESA_Nk-20:9797   Min.   :811   ENSG00000000419.8 :   1  
##                            1st Qu.:811   ENSG00000000457.8 :   1  
##                            Median :811   ENSG00000000460.12:   1  
##                            Mean   :811   ENSG00000000938.8 :   1  
##                            3rd Qu.:811   ENSG00000000971.11:   1  
##                            Max.   :811   ENSG00000001036.8 :   1  
##                                          (Other)           :9791  
##       gene           chr           start                end           
##  A1BG   :   1   chr1   :1062   Min.   :    14363   Min.   :    29370  
##  AAAS   :   1   chr19  : 752   1st Qu.: 31191920   1st Qu.: 31230667  
##  AACS   :   1   chr2   : 657   Median : 57647548   Median : 57698944  
##  AAED1  :   1   chr17  : 618   Mean   : 72897113   Mean   : 72948622  
##  AAGAB  :   1   chr11  : 607   3rd Qu.:108320411   3rd Qu.:108507766  
##  AAK1   :   1   chr3   : 584   Max.   :249200395   Max.   :249214145  
##  (Other):9791   (Other):5517                                          
##     pop1.h2          pop1.se          pop2.h2          pop2.se      
##  Min.   :0.0000   Min.   :0.0046   Min.   :0.0000   Min.   :0.0026  
##  1st Qu.:0.0051   1st Qu.:0.0524   1st Qu.:0.0052   1st Qu.:0.0203  
##  Median :0.0543   Median :0.0661   Median :0.0333   Median :0.0282  
##  Mean   :0.1171   Mean   :0.0663   Mean   :0.1091   Mean   :0.0322  
##  3rd Qu.:0.1643   3rd Qu.:0.0803   3rd Qu.:0.1376   3rd Qu.:0.0441  
##  Max.   :0.9569   Max.   :0.1286   Max.   :0.9802   Max.   :0.0924  
##  NA's   :570      NA's   :570      NA's   :570      NA's   :570     
##        rG              rG.se              chrnum       pop1.snpcount   
##  Min.   :-1.0000   Min.   :    0.01   Min.   : 1.000   Min.   :   6.0  
##  1st Qu.: 0.1916   1st Qu.:    0.36   1st Qu.: 4.000   1st Qu.: 370.0  
##  Median : 0.9979   Median :    1.06   Median :10.000   Median : 529.0  
##  Mean   : 0.4847   Mean   : 5317.00   Mean   : 9.934   Mean   : 527.6  
##  3rd Qu.: 1.0000   3rd Qu.:    8.93   3rd Qu.:16.000   3rd Qu.: 665.0  
##  Max.   : 1.0000   Max.   :70554.28   Max.   :22.000   Max.   :3065.0  
##  NA's   :570       NA's   :570                                         
##  pop2.snpcount      min.h2           max.h2      
##  Min.   :   1   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.: 319   1st Qu.:0.0029   1st Qu.:0.0141  
##  Median : 460   Median :0.0218   Median :0.0756  
##  Mean   : 460   Mean   :0.0843   Mean   :0.1419  
##  3rd Qu.: 582   3rd Qu.:0.0979   3rd Qu.:0.1965  
##  Max.   :2728   Max.   :0.9569   Max.   :0.9802  
##                 NA's   :570      NA's   :570
## Warning: Removed 570 rows containing missing values (geom_point).

## Warning: Removed 570 rows containing missing values (geom_point).

## Warning: Removed 570 rows containing missing values (geom_point).

## Warning: Removed 570 rows containing missing values (geom_point).

## Warning: Removed 570 rows containing missing values (geom_point).

## Warning: Removed 570 rows containing missing values (geom_point).

## Warning: Removed 570 rows containing missing values (geom_point).

## Warning: Removed 570 rows containing non-finite values (stat_density2d).

## Warning: Removed 570 rows containing missing values (geom_point).

## Warning: Removed 570 rows containing missing values (geom_point).

## Warning: Removed 570 rows containing missing values (geom_point).

## Warning: Removed 570 rows containing non-finite values (stat_density2d).

##                pop.data          N                      ensid     
##  AFA-CAU_MESA_Nk-20:2272   Min.   :811   ENSG00000000457.8 :   1  
##                            1st Qu.:811   ENSG00000001084.6 :   1  
##                            Median :811   ENSG00000001561.6 :   1  
##                            Mean   :811   ENSG00000001631.10:   1  
##                            3rd Qu.:811   ENSG00000002549.8 :   1  
##                            Max.   :811   ENSG00000002822.11:   1  
##                                          (Other)           :2266  
##       gene           chr           start                end           
##  AAGAB  :   1   chr1   : 237   Min.   :    62293   Min.   :   103628  
##  AAR2   :   1   chr6   : 144   1st Qu.: 29686343   1st Qu.: 29748518  
##  AASDH  :   1   chr11  : 142   Median : 58057341   Median : 58155214  
##  ABAT   :   1   chr2   : 137   Mean   : 72073652   Mean   : 72128136  
##  ABCA7  :   1   chr19  : 135   3rd Qu.:107879509   3rd Qu.:107950688  
##  ABCB10 :   1   chr12  : 134   Max.   :249132479   Max.   :249143716  
##  (Other):2266   (Other):1343                                          
##     pop1.h2            pop1.se           pop2.h2        
##  Min.   :0.000017   Min.   :0.01387   Min.   :0.000037  
##  1st Qu.:0.218694   1st Qu.:0.07684   1st Qu.:0.192619  
##  Median :0.293381   Median :0.08504   Median :0.292032  
##  Mean   :0.332921   Mean   :0.08363   Mean   :0.328373  
##  3rd Qu.:0.428686   3rd Qu.:0.09284   3rd Qu.:0.458162  
##  Max.   :0.956931   Max.   :0.12857   Max.   :0.980233  
##                                                         
##     pop2.se               rG              rG.se               chrnum      
##  Min.   :0.003337   Min.   :-1.0000   Min.   :   0.0075   Min.   : 1.000  
##  1st Qu.:0.043925   1st Qu.: 0.8204   1st Qu.:   0.1021   1st Qu.: 4.000  
##  Median :0.051976   Median : 0.9838   Median :   0.1806   Median :10.000  
##  Mean   :0.049661   Mean   : 0.8313   Mean   :   1.3737   Mean   : 9.901  
##  3rd Qu.:0.057356   3rd Qu.: 1.0000   3rd Qu.:   0.2853   3rd Qu.:16.000  
##  Max.   :0.092402   Max.   : 1.0000   Max.   :1588.4756   Max.   :22.000  
##                                                                           
##  pop1.snpcount    pop2.snpcount        min.h2             max.h2      
##  Min.   :  57.0   Min.   :  50.0   Min.   :0.000017   Min.   :0.2001  
##  1st Qu.: 427.0   1st Qu.: 368.0   1st Qu.:0.125627   1st Qu.:0.2617  
##  Median : 572.0   Median : 499.5   Median :0.220588   Median :0.3496  
##  Mean   : 571.9   Mean   : 500.3   Mean   :0.262645   Mean   :0.3986  
##  3rd Qu.: 705.0   3rd Qu.: 618.0   3rd Qu.:0.360196   3rd Qu.:0.5013  
##  Max.   :1486.0   Max.   :1268.0   Max.   :0.956931   Max.   :0.9802  
## 

## Warning: Removed 570 rows containing non-finite values (stat_density2d).

## Warning: Removed 570 rows containing non-finite values (stat_density).

## Warning: Removed 570 rows containing non-finite values (stat_density).

## Warning: Removed 570 rows containing non-finite values (stat_density).

## Warning: Removed 570 rows containing non-finite values (stat_density).

## Warning: Removed 570 rows containing non-finite values (stat_bin2d).

## Warning: Removed 570 rows containing missing values (geom_point).

## `geom_smooth()` using method = 'gam'
## Warning: Removed 570 rows containing non-finite values (stat_smooth).

## Warning: Removed 570 rows containing missing values (geom_point).

## `geom_smooth()` using method = 'gam'
## Warning: Removed 570 rows containing non-finite values (stat_smooth).

## Warning: Removed 570 rows containing missing values (geom_point).
## Warning in cor.test.default(res$rG, res$pop1.snpcount, method = "s"):
## Cannot compute exact p-value with ties
## Warning in cor.test.default(res$rG, res$pop2.snpcount, method = "s"):
## Cannot compute exact p-value with ties

##                pop.data          N                      ensid     
##  AFA-HIS_MESA_Nk-20:9797   Min.   :585   ENSG00000000419.8 :   1  
##                            1st Qu.:585   ENSG00000000457.8 :   1  
##                            Median :585   ENSG00000000460.12:   1  
##                            Mean   :585   ENSG00000000938.8 :   1  
##                            3rd Qu.:585   ENSG00000000971.11:   1  
##                            Max.   :585   ENSG00000001036.8 :   1  
##                                          (Other)           :9791  
##       gene           chr           start                end           
##  A1BG   :   1   chr1   :1062   Min.   :    14363   Min.   :    29370  
##  AAAS   :   1   chr19  : 752   1st Qu.: 31191920   1st Qu.: 31230667  
##  AACS   :   1   chr2   : 657   Median : 57647548   Median : 57698944  
##  AAED1  :   1   chr17  : 618   Mean   : 72897113   Mean   : 72948622  
##  AAGAB  :   1   chr11  : 607   3rd Qu.:108320411   3rd Qu.:108507766  
##  AAK1   :   1   chr3   : 584   Max.   :249200395   Max.   :249214145  
##  (Other):9791   (Other):5517                                          
##     pop1.h2          pop1.se          pop2.h2          pop2.se      
##  Min.   :0.0000   Min.   :0.0092   Min.   :0.0000   Min.   :0.0050  
##  1st Qu.:0.0059   1st Qu.:0.0511   1st Qu.:0.0061   1st Qu.:0.0361  
##  Median :0.0549   Median :0.0641   Median :0.0521   Median :0.0483  
##  Mean   :0.1168   Mean   :0.0645   Mean   :0.1270   Mean   :0.0495  
##  3rd Qu.:0.1624   3rd Qu.:0.0782   3rd Qu.:0.1778   3rd Qu.:0.0635  
##  Max.   :0.8738   Max.   :0.1286   Max.   :0.9217   Max.   :0.1022  
##  NA's   :528      NA's   :528      NA's   :528      NA's   :528     
##        rG              rG.se              chrnum       pop1.snpcount   
##  Min.   :-1.0000   Min.   :    0.01   Min.   : 1.000   Min.   :   6.0  
##  1st Qu.: 0.5667   1st Qu.:    0.34   1st Qu.: 4.000   1st Qu.: 370.0  
##  Median : 1.0000   Median :    1.08   Median :10.000   Median : 529.0  
##  Mean   : 0.5744   Mean   : 7249.01   Mean   : 9.934   Mean   : 527.6  
##  3rd Qu.: 1.0000   3rd Qu.:    9.59   3rd Qu.:16.000   3rd Qu.: 665.0  
##  Max.   : 1.0000   Max.   :84785.94   Max.   :22.000   Max.   :3065.0  
##  NA's   :528       NA's   :528                                         
##  pop2.snpcount        min.h2           max.h2      
##  Min.   :   6.0   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.: 370.0   1st Qu.:0.0033   1st Qu.:0.0159  
##  Median : 529.0   Median :0.0287   Median :0.0826  
##  Mean   : 528.4   Mean   :0.0957   Mean   :0.1481  
##  3rd Qu.: 667.0   3rd Qu.:0.1224   3rd Qu.:0.2102  
##  Max.   :3054.0   Max.   :0.8738   Max.   :0.9217  
##                   NA's   :528      NA's   :528
## Warning: Removed 528 rows containing missing values (geom_point).

## Warning: Removed 528 rows containing missing values (geom_point).

## Warning: Removed 528 rows containing missing values (geom_point).

## Warning: Removed 528 rows containing missing values (geom_point).

## Warning: Removed 528 rows containing missing values (geom_point).

## Warning: Removed 528 rows containing missing values (geom_point).

## Warning: Removed 528 rows containing missing values (geom_point).

## Warning: Removed 528 rows containing non-finite values (stat_density2d).

## Warning: Removed 528 rows containing missing values (geom_point).

## Warning: Removed 528 rows containing missing values (geom_point).

## Warning: Removed 528 rows containing missing values (geom_point).

## Warning: Removed 528 rows containing non-finite values (stat_density2d).

##                pop.data          N                      ensid     
##  AFA-HIS_MESA_Nk-20:2452   Min.   :585   ENSG00000000457.8 :   1  
##                            1st Qu.:585   ENSG00000001084.6 :   1  
##                            Median :585   ENSG00000001561.6 :   1  
##                            Mean   :585   ENSG00000001631.10:   1  
##                            3rd Qu.:585   ENSG00000002549.8 :   1  
##                            Max.   :585   ENSG00000002822.11:   1  
##                                          (Other)           :2446  
##       gene           chr           start                end           
##  AAGAB  :   1   chr1   : 255   Min.   :    96407   Min.   :   103628  
##  AASDH  :   1   chr6   : 157   1st Qu.: 29755679   1st Qu.: 29901554  
##  ABAT   :   1   chr2   : 151   Median : 58223710   Median : 58234066  
##  ABCA7  :   1   chr11  : 150   Mean   : 72229107   Mean   : 72282598  
##  ABCB10 :   1   chr19  : 147   3rd Qu.:108838558   3rd Qu.:108863164  
##  ABCC3  :   1   chr12  : 146   Max.   :249104650   Max.   :249120832  
##  (Other):2446   (Other):1446                                          
##     pop1.h2            pop1.se           pop2.h2            pop2.se       
##  Min.   :0.000097   Min.   :0.02457   Min.   :0.000094   Min.   :0.01511  
##  1st Qu.:0.203427   1st Qu.:0.07368   1st Qu.:0.225010   1st Qu.:0.06202  
##  Median :0.281652   Median :0.08202   Median :0.318536   Median :0.06906  
##  Mean   :0.317939   Mean   :0.08082   Mean   :0.358031   Mean   :0.06670  
##  3rd Qu.:0.414189   3rd Qu.:0.08926   3rd Qu.:0.467325   3rd Qu.:0.07415  
##  Max.   :0.873794   Max.   :0.11604   Max.   :0.921703   Max.   :0.10223  
##                                                                           
##        rG              rG.se               chrnum       pop1.snpcount 
##  Min.   :-1.0000   Min.   :  0.01333   Min.   : 1.000   Min.   :  57  
##  1st Qu.: 0.9123   1st Qu.:  0.09989   1st Qu.: 4.000   1st Qu.: 429  
##  Median : 1.0000   Median :  0.17433   Median : 9.000   Median : 572  
##  Mean   : 0.9075   Mean   :  0.46734   Mean   : 9.842   Mean   : 571  
##  3rd Qu.: 1.0000   3rd Qu.:  0.27529   3rd Qu.:15.250   3rd Qu.: 703  
##  Max.   : 1.0000   Max.   :217.88082   Max.   :22.000   Max.   :1486  
##                                                                       
##  pop2.snpcount        min.h2             max.h2      
##  Min.   :  59.0   Min.   :0.000094   Min.   :0.2001  
##  1st Qu.: 427.8   1st Qu.:0.152918   1st Qu.:0.2617  
##  Median : 573.0   Median :0.241634   Median :0.3520  
##  Mean   : 571.8   Mean   :0.281497   Mean   :0.3945  
##  3rd Qu.: 705.0   3rd Qu.:0.375367   3rd Qu.:0.4865  
##  Max.   :1480.0   Max.   :0.873794   Max.   :0.9217  
## 

## Warning: Removed 528 rows containing non-finite values (stat_density2d).

## Warning: Removed 528 rows containing non-finite values (stat_density).

## Warning: Removed 528 rows containing non-finite values (stat_density).

## Warning: Removed 528 rows containing non-finite values (stat_density).

## Warning: Removed 528 rows containing non-finite values (stat_density).

## Warning: Removed 528 rows containing non-finite values (stat_bin2d).

## Warning: Removed 528 rows containing missing values (geom_point).

## `geom_smooth()` using method = 'gam'
## Warning: Removed 528 rows containing non-finite values (stat_smooth).
## Warning: Removed 528 rows containing missing values (geom_point).

## `geom_smooth()` using method = 'gam'
## Warning: Removed 528 rows containing non-finite values (stat_smooth).

## Warning: Removed 528 rows containing missing values (geom_point).
## Warning in cor.test.default(res$rG, res$pop1.snpcount, method = "s"):
## Cannot compute exact p-value with ties
## Warning in cor.test.default(res$rG, res$pop2.snpcount, method = "s"):
## Cannot compute exact p-value with ties

##                pop.data          N                      ensid     
##  CAU-HIS_MESA_Nk-20:9797   Min.   :930   ENSG00000000419.8 :   1  
##                            1st Qu.:930   ENSG00000000457.8 :   1  
##                            Median :930   ENSG00000000460.12:   1  
##                            Mean   :930   ENSG00000000938.8 :   1  
##                            3rd Qu.:930   ENSG00000000971.11:   1  
##                            Max.   :930   ENSG00000001036.8 :   1  
##                                          (Other)           :9791  
##       gene           chr           start                end           
##  A1BG   :   1   chr1   :1062   Min.   :    14363   Min.   :    29370  
##  AAAS   :   1   chr19  : 752   1st Qu.: 31191920   1st Qu.: 31230667  
##  AACS   :   1   chr2   : 657   Median : 57647548   Median : 57698944  
##  AAED1  :   1   chr17  : 618   Mean   : 72897113   Mean   : 72948622  
##  AAGAB  :   1   chr11  : 607   3rd Qu.:108320411   3rd Qu.:108507766  
##  AAK1   :   1   chr3   : 584   Max.   :249200395   Max.   :249214145  
##  (Other):9791   (Other):5517                                          
##     pop1.h2          pop1.se          pop2.h2          pop2.se      
##  Min.   :0.0000   Min.   :0.0011   Min.   :0.0000   Min.   :0.0041  
##  1st Qu.:0.0051   1st Qu.:0.0204   1st Qu.:0.0045   1st Qu.:0.0305  
##  Median :0.0363   Median :0.0280   Median :0.0433   Median :0.0411  
##  Mean   :0.1068   Mean   :0.0314   Mean   :0.1130   Mean   :0.0432  
##  3rd Qu.:0.1341   3rd Qu.:0.0421   3rd Qu.:0.1502   3rd Qu.:0.0563  
##  Max.   :0.9786   Max.   :0.0864   Max.   :0.9834   Max.   :0.0941  
##  NA's   :317      NA's   :317      NA's   :317      NA's   :317     
##        rG              rG.se              chrnum       pop1.snpcount 
##  Min.   :-1.0000   Min.   :    0.00   Min.   : 1.000   Min.   :   1  
##  1st Qu.: 0.7060   1st Qu.:    0.21   1st Qu.: 4.000   1st Qu.: 319  
##  Median : 1.0000   Median :    0.76   Median :10.000   Median : 460  
##  Mean   : 0.6217   Mean   : 3859.83   Mean   : 9.934   Mean   : 460  
##  3rd Qu.: 1.0000   3rd Qu.:    6.33   3rd Qu.:16.000   3rd Qu.: 582  
##  Max.   : 1.0000   Max.   :54431.91   Max.   :22.000   Max.   :2728  
##  NA's   :317       NA's   :317                                       
##  pop2.snpcount        min.h2           max.h2      
##  Min.   :   6.0   Min.   :0.0000   Min.   :0.0000  
##  1st Qu.: 370.0   1st Qu.:0.0026   1st Qu.:0.0120  
##  Median : 529.0   Median :0.0231   Median :0.0573  
##  Mean   : 528.4   Mean   :0.0925   Mean   :0.1273  
##  3rd Qu.: 667.0   3rd Qu.:0.1113   3rd Qu.:0.1716  
##  Max.   :3054.0   Max.   :0.9786   Max.   :0.9834  
##                   NA's   :317      NA's   :317
## Warning: Removed 317 rows containing missing values (geom_point).

## Warning: Removed 317 rows containing missing values (geom_point).

## Warning: Removed 317 rows containing missing values (geom_point).

## Warning: Removed 317 rows containing missing values (geom_point).

## Warning: Removed 317 rows containing missing values (geom_point).

## Warning: Removed 317 rows containing missing values (geom_point).

## Warning: Removed 317 rows containing missing values (geom_point).

## Warning: Removed 317 rows containing non-finite values (stat_density2d).

## Warning: Removed 317 rows containing missing values (geom_point).

## Warning: Removed 317 rows containing missing values (geom_point).

## Warning: Removed 317 rows containing missing values (geom_point).

## Warning: Removed 317 rows containing non-finite values (stat_density2d).

##                pop.data          N                      ensid     
##  CAU-HIS_MESA_Nk-20:2051   Min.   :930   ENSG00000001561.6 :   1  
##                            1st Qu.:930   ENSG00000002822.11:   1  
##                            Median :930   ENSG00000002933.3 :   1  
##                            Mean   :930   ENSG00000003056.3 :   1  
##                            3rd Qu.:930   ENSG00000003393.10:   1  
##                            Max.   :930   ENSG00000003402.14:   1  
##                                          (Other)           :2045  
##       gene           chr           start                end           
##  AAGAB  :   1   chr1   : 207   Min.   :    62293   Min.   :   103628  
##  AAR2   :   1   chr11  : 134   1st Qu.: 28348054   1st Qu.: 28562072  
##  AASDH  :   1   chr6   : 134   Median : 57994127   Median : 58154136  
##  ABAT   :   1   chr19  : 127   Mean   : 71868524   Mean   : 71920540  
##  ABCA7  :   1   chr17  : 122   3rd Qu.:107995865   3rd Qu.:108072570  
##  ABCC3  :   1   chr7   : 120   Max.   :247581351   Max.   :247612119  
##  (Other):2045   (Other):1207                                          
##     pop1.h2            pop1.se            pop2.h2        
##  Min.   :0.000146   Min.   :0.003304   Min.   :0.001276  
##  1st Qu.:0.218156   1st Qu.:0.045296   1st Qu.:0.235171  
##  Median :0.312824   Median :0.050967   Median :0.320943  
##  Mean   :0.353212   Mean   :0.049529   Mean   :0.368179  
##  3rd Qu.:0.470564   3rd Qu.:0.055119   3rd Qu.:0.470548  
##  Max.   :0.978634   Max.   :0.086425   Max.   :0.983391  
##                                                          
##     pop2.se               rG              rG.se              chrnum      
##  Min.   :0.004056   Min.   :-1.0000   Min.   : 0.00234   Min.   : 1.000  
##  1st Qu.:0.058120   1st Qu.: 0.9540   1st Qu.: 0.04368   1st Qu.: 5.000  
##  Median :0.063636   Median : 1.0000   Median : 0.08111   Median :10.000  
##  Mean   :0.062446   Mean   : 0.9463   Mean   : 0.14746   Mean   : 9.975  
##  3rd Qu.:0.068726   3rd Qu.: 1.0000   3rd Qu.: 0.12859   3rd Qu.:16.000  
##  Max.   :0.094097   Max.   : 1.0000   Max.   :69.73787   Max.   :22.000  
##                                                                          
##  pop1.snpcount    pop2.snpcount        min.h2             max.h2      
##  Min.   :  50.0   Min.   :  59.0   Min.   :0.000146   Min.   :0.2001  
##  1st Qu.: 365.0   1st Qu.: 424.0   1st Qu.:0.188851   1st Qu.:0.2564  
##  Median : 496.0   Median : 570.0   Median :0.275619   Median :0.3511  
##  Mean   : 498.7   Mean   : 569.9   Mean   :0.322138   Mean   :0.3993  
##  3rd Qu.: 619.5   3rd Qu.: 704.0   3rd Qu.:0.432113   3rd Qu.:0.5011  
##  Max.   :1268.0   Max.   :1480.0   Max.   :0.978634   Max.   :0.9834  
## 

## Warning: Removed 317 rows containing non-finite values (stat_density2d).

## Warning: Removed 317 rows containing non-finite values (stat_density).

## Warning: Removed 317 rows containing non-finite values (stat_density).

## Warning: Removed 317 rows containing non-finite values (stat_density).

## Warning: Removed 317 rows containing non-finite values (stat_density).

## Warning: Removed 317 rows containing non-finite values (stat_bin2d).

## Warning: Removed 317 rows containing missing values (geom_point).

## `geom_smooth()` using method = 'gam'
## Warning: Removed 317 rows containing non-finite values (stat_smooth).
## Warning: Removed 317 rows containing missing values (geom_point).

## `geom_smooth()` using method = 'gam'
## Warning: Removed 317 rows containing non-finite values (stat_smooth).

## Warning: Removed 317 rows containing missing values (geom_point).
## Warning in cor.test.default(res$rG, res$pop1.snpcount, method = "s"):
## Cannot compute exact p-value with ties
## Warning in cor.test.default(res$rG, res$pop2.snpcount, method = "s"):
## Cannot compute exact p-value with ties